#include "FieldNode.h"

#include "Output/Console.h"

#include "Output/Console.h"
#include "ScriptCompiler/Token/Token.h"
#include "ScriptCompiler/AST/TypeNode.h"
#include "ScriptCompiler/AST/AccessLevelNode.h"
#include "ScriptCompiler/AST/ParameterNode.h"
#include "ScriptCompiler/AST/SentenceBlockNode.h"
#include "ScriptCompiler/AST/ExpressionNode.h"
#include "ScriptCompiler/AST/DecoratorNode.h"

void CGSharpFieldNode::DebugPrint(int32_t InDepth)
{
    //print blank spaces for depth
    for(int32_t i=0;i<InDepth;i++)
    {
        WH::Print(U"\t");
    }

    if(AccessLevel.HasValue())
    {
        //print access level
        AccessLevel.GetValue()->DebugPrint(0);
        WH::Print(U" ");
    }

    if(Decorator)
    {
        Decorator->DebugPrint(0);
        WH::Print(U" ");
    }

    //print field type
    Type->DebugPrint(0);

    WH::Print(U" ");

    
    if(Assignment.HasValue())
    {
        Assignment.GetValue()->DebugPrint(0);
        WH::Print(U";\n");
    }
    else
    {
        //print field name
        WH::Print(U" " + Name->ToString() + U";\n");
    }
}

std::shared_ptr<CScriptToken> CGSharpFieldNode::GetFirstToken()
{
    if(AccessLevel.HasValue())
    {
        return AccessLevel.GetValue()->GetFirstToken();
    }
    else
    {
        return Type->GetFirstToken();
    }
}
